package com.whj.apipassenger.controller;

import com.whj.apipassenger.remote.ServiceOrderClient;
import com.whj.internalcommon.dto.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import javax.xml.ws.Service;

/**
 * @Auther: wanghaijun
 * @Date: 2022/12/25 - 12 - 25 - 16:18 
 * @Description: com.whj.apipassenger.controller
 */

@RestController
public class TestController {

    @GetMapping("/test")
    public String test(){
        return "test api passenger";
    }

    /**
     * 需要token的测试
     * @return
     */
    @GetMapping("/auth")
    public ResponseResult authTest(){
        return ResponseResult.success("auth Test");
    }

    /**
     * 不需要token的测试
     * @return
     */
    @GetMapping("/noauth")
    public ResponseResult noAuthTest(){
        return ResponseResult.success("no auth Test");
    }


    @Autowired
    private ServiceOrderClient serviceOrderClient;
    /**
     * 测试派单逻辑
     *
     * @param orderId
     * @return
     */
    @GetMapping("/test/{orderId}")
    public String dispatchRealTimeOrder(@PathVariable("orderId") Long orderId){

        System.out.println("并发请求的orderId = " + orderId);
        String s = serviceOrderClient.dispatchRealTimeOrder(orderId);
        return s;
    }
}
